package com.dhcc.nurtv;

import android.Manifest;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        WebUtil.handleSSLHandshake();
        super.onCreate(savedInstanceState);
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.INTERNET, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 1);

        setContentView(R.layout.activity_main);
        WebView webView = findViewById(R.id.webview);
        //清除缓存
        webView.clearCache(true);
        //清除应用所有缓存
//        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
//        am.clearApplicationUserData();
        //本地加载
        // WebUtil.init(webView,"file:///android_asset/apps/H53DE0C90/www/index.html");

        //外网加载
        WebUtil.init(webView,"https://114.242.246.235:1443/imedical/web/scripts/nurse/nurtv/index.html");
        // WebUtil.init(webView,"https://140.143.188.73:1443/imedical/web/scripts/nurse/nurtv/index.html");

        //延迟五秒
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                webView.loadUrl("javascript:received('"+"测试传递"+"')");
            }
        }, 5000);
        // 崩溃日志
        CrashHandler.getInstance().init(this);
    }
}